#include<bits/stdc++.h>
using namespace std;
#define int long long
bool check(int n)
{
//	vector<int> a;
	int a[8];
	int k = 0;
	while (n) {
		a[k++] = n % 10;
		n /= 10;
	}
	for (int i = 0 ; i < 4 ; i++) {
		if (a[i] != a[8 - i - 1]) {
			return 0;
		}
	}
	return 1;
}
bool judge(int n)
{
	int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

	int year = n / 10000;
	int mon = n % 10000 / 100;
	int day = n % 100;
	if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
		days[2] ++;
	}
	if (mon >= 1 && mon <= 12) {
		if (day >= 1 && day <= days[mon]) {
			return 1;
		}
	}


	return 0;
}
signed main()
{
	int n, m;
	cin >> n >> m;
	int cnt = 0;
	for (int i = n ; i <= m ; i ++) {// 3WA 忘记加等号
//		if (judge (i)) {
//			if (i % 11 == 0)cnt++;
//		}
		if (judge (i) && check(i)) cnt ++;
	}
	cout << cnt << endl ;
	return 0;
}
